import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EnterpriseQuery, EnterpriseVO, MerchantAccountCreateXnForm, SetYwyForm, addOrEditForm, MerchantAccountListFpForm } from './types';

/**
 * 查询业务员列表
 * @param query
 */
export const enterpriseList = (query: EnterpriseQuery): AxiosPromise<EnterpriseVO[]> => {
  return request({
    url: '/payment/merchant/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询业务员
 */
export const channelSalesman = () => {
  return request({
    url: '/payment/channelSalesman/ywyList',
    method: 'get',
  });
};

/**
 * 配置业务员
 */
export const setYwy = (data: SetYwyForm) => {
  return request({
    url: '/payment/merchant/setYwy',
    method: 'post',
    params: data
  });
};

/**
 * 解绑业务员
 */
export const ubYwy = (id: string | number) => {
  return request({
    url: '/payment/merchant/ubYwy',
    method: 'post',
    params: {
      id
    }
  });
};

/**
 * 省市区联动
 */
export const areaQueryList = (up?: string | number) => {
  return request({
    url: '/system/area/queryList',
    method: 'post',
    params: {
      up
    }
  });
};

/**
 * 行业查询
 */
export const selList = () => {
  return request({
    url: '/system/industry/selList',
    method: 'get',
  });
};

/**
 * 添加企业
 */
export const addMerchant = (data: addOrEditForm) => {
  return request({
    url: '/payment/merchant',
    method: 'post',
    data,
  });
};



/**
 * 审核企业
*/
export const checkMerchant = (data) => {
  return request({
    url: `/payment/merchant/chk`,
    method: 'post',
    headers: {
    	  'Content-Type': 'application/x-www-form-urlencoded'
    },
    data
  });
};




/**
 * 企业详情
*/
export const merchantDetail = (id: string | number) => {
  return request({
    url: `/payment/merchant/${id}`,
    method: 'get',
  });
};

/**
 * 修改企业
 */
export const editMerchant = (data: addOrEditForm) => {
  return request({
    url: '/payment/merchant',
    method: 'put',
    data,
  });
};

/**
 * 虚拟户列表查询
 */
export const merchantAccountListFp = (params: MerchantAccountListFpForm) => {
  return request({
    url: 'payment/merchantAccount/listFp',
    method: 'get',
    params,
  });
};

/**
 * 创建虚拟户
 */
export const merchantAccountCreateXn = (params: MerchantAccountCreateXnForm) => {
  return request({
    url: 'payment/merchantAccount/createXn',
    method: 'post',
    params,
  });
};

export default {
  enterpriseList,
  channelSalesman,
  setYwy,
  ubYwy,
  areaQueryList,
  selList,
  addMerchant,
  merchantDetail,
  editMerchant,
  merchantAccountListFp,
  merchantAccountCreateXn,
  checkMerchant
};
